package vip.xiaonuo.device.modular.service.impl;

import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import vip.xiaonuo.device.modular.mapper.CabinetDoorMapper;
import vip.xiaonuo.device.modular.mapper.GoodsLedgerMapper;
import vip.xiaonuo.device.modular.mapper.UserMapper;
import vip.xiaonuo.device.vo.CabinetScreenAdminVO;
import vip.xiaonuo.device.vo.CabinetScreenDoorVO;
import vip.xiaonuo.device.vo.CabinetScreenGoodsLedgerVO;
import vip.xiaonuo.device.vo.Result;

import javax.annotation.Resource;

/**
 * @author 墨塵
 * @since 2023/1/5
 */
@Service("deviceCabinetAdminService")
public class DeviceCabinetAdminServiceImpl extends DeviceBaseService{

    @Resource
    private UserMapper userMapper;

    @Override
    protected Integer getReqType() {
        return null;
    }

    @Override
    protected Boolean getLogFlag() {
        return false;
    }

    @Override
    protected Result handle(JSONObject param) {
        String cabinetGroupId = param.getString("cabinetGroupId");
        String cabinetId = param.getString("cabinetId");
        String cabinetDoorId = param.getString("cabinetDoorId");
        CabinetScreenAdminVO adminVO = new CabinetScreenAdminVO();
        if(StringUtils.isNotBlank(cabinetGroupId)){
            adminVO.setCabGroupAdminList(userMapper.getAdminListForCabGroup(cabinetGroupId));
        }
        if(StringUtils.isNotBlank(cabinetId)){
            adminVO.setCabAdminList(userMapper.getAdminListForCabInfo(cabinetId));
        }
        if(StringUtils.isNotBlank(cabinetDoorId)){
            adminVO.setCabDoorAdminList(userMapper.getAdminListForCabDoor(cabinetDoorId));
        }
        return Result.ok(adminVO);
    }
}
